From 11bc179120c62c4948827effded2c802f66bfb58 Mon Sep 17 00:00:00 2001 From: "djm@kirby.fc.hp.com" Date: Tue, 30 Aug 2005 17:51:51 -0600 Subject: [PATCH] Baby step toward host SMP support --- xen/arch/ia64/linux-xen/mm_contig.c | 4 ++-- xen/arch/ia64/linux-xen/smp.c | 15 +++++++++++-- xen/arch/ia64/linux-xen/smpboot.c | 3 ++- xen/arch/ia64/vcpu.c | 2 ++ xen/arch/ia64/xenmisc.c | 7 +++++- xen/arch/ia64/xensetup.c | 35 +++++++++++++++++++++++++++++ 6 files changed, 60 insertions(+), 6 deletions(-) diff --git a/xen/arch/ia64/linux-xen/mm_contig.c b/xen/arch/ia64/linux-xen/mm_contig.c index 87ab66deca..f3a3b39a48 100644 --- a/xen/arch/ia64/linux-xen/mm_contig.c +++ b/xen/arch/ia64/linux-xen/mm_contig.c @@ -192,8 +192,8 @@ per_cpu_init (void) */ if (smp_processor_id() == 0) { #ifdef XEN - cpu_data = alloc_xenheap_pages(PERCPU_PAGE_SIZE - - PAGE_SIZE + get_order(NR_CPUS)); + cpu_data = alloc_xenheap_pages(PERCPU_PAGE_SHIFT - + PAGE_SHIFT + get_order(NR_CPUS)); #else cpu_data = __alloc_bootmem(PERCPU_PAGE_SIZE * NR_CPUS, PERCPU_PAGE_SIZE, __pa(MAX_DMA_ADDRESS)); diff --git a/xen/arch/ia64/linux-xen/smp.c b/xen/arch/ia64/linux-xen/smp.c index 872ea4b025..28c294a247 100644 --- a/xen/arch/ia64/linux-xen/smp.c +++ b/xen/arch/ia64/linux-xen/smp.c @@ -63,7 +63,8 @@ void flush_tlb_mask(cpumask_t mask) //Huh? This seems to be used on ia64 even if !CONFIG_SMP void smp_send_event_check_mask(cpumask_t mask) { - dummy(); + printf("smp_send_event_check_mask called\n"); + //dummy(); //send_IPI_mask(cpu_mask, EVENT_CHECK_VECTOR); } @@ -378,7 +379,11 @@ smp_call_function (void (*func) (void *info), void *info, int nonatomic, int wai /* Can deadlock when called with interrupts disabled */ #ifdef XEN - if (irqs_disabled()) panic("smp_call_function called with interrupts disabled\n"); + if (irqs_disabled()) { + printk("smp_call_function called with interrupts disabled..."); + printk("enabling interrupts\n"); + local_irq_enable(); + } #else WARN_ON(irqs_disabled()); #endif @@ -390,11 +395,15 @@ smp_call_function (void (*func) (void *info), void *info, int nonatomic, int wai if (wait) atomic_set(&data.finished, 0); + printk("smp_call_function: about to spin_lock \n"); spin_lock(&call_lock); + printk("smp_call_function: done with spin_lock \n"); call_data = &data; mb(); /* ensure store to call_data precedes setting of IPI_CALL_FUNC */ + printk("smp_call_function: about to send_IPI \n"); send_IPI_allbutself(IPI_CALL_FUNC); + printk("smp_call_function: done with send_IPI \n"); /* Wait for response */ while (atomic_read(&data.started) != cpus) @@ -405,7 +414,9 @@ smp_call_function (void (*func) (void *info), void *info, int nonatomic, int wai cpu_relax(); call_data = NULL; + printk("smp_call_function: about to spin_unlock \n"); spin_unlock(&call_lock); + printk("smp_call_function: DONE WITH spin_unlock, returning \n"); return 0; } EXPORT_SYMBOL(smp_call_function); diff --git a/xen/arch/ia64/linux-xen/smpboot.c b/xen/arch/ia64/linux-xen/smpboot.c index 92c9dec161..1c0e84e31d 100644 --- a/xen/arch/ia64/linux-xen/smpboot.c +++ b/xen/arch/ia64/linux-xen/smpboot.c @@ -68,7 +68,8 @@ int ht_per_core = 1; #ifdef CONFIG_SMP /* ifdef XEN */ -#define SMP_DEBUG 0 +//#define SMP_DEBUG 0 +#define SMP_DEBUG 1 #if SMP_DEBUG #define Dprintk(x...) printk(x) diff --git a/xen/arch/ia64/vcpu.c b/xen/arch/ia64/vcpu.c index b1cd4dea60..55af8a49e4 100644 --- a/xen/arch/ia64/vcpu.c +++ b/xen/arch/ia64/vcpu.c @@ -586,6 +586,7 @@ void vcpu_pend_interrupt(VCPU *vcpu, UINT64 vector) PSCB(vcpu,pending_interruption) = 1; } +#if 0 /* Keir: I think you should unblock when an interrupt is pending. */ { int running = test_bit(_VCPUF_running, &vcpu->vcpu_flags); @@ -593,6 +594,7 @@ void vcpu_pend_interrupt(VCPU *vcpu, UINT64 vector) if ( running ) smp_send_event_check_cpu(vcpu->processor); } +#endif } void early_tick(VCPU *vcpu) diff --git a/xen/arch/ia64/xenmisc.c b/xen/arch/ia64/xenmisc.c index c76a93eca8..701614130e 100644 --- a/xen/arch/ia64/xenmisc.c +++ b/xen/arch/ia64/xenmisc.c @@ -28,7 +28,12 @@ void ia64_mca_init(void) { printf("ia64_mca_init() skipped (Machine check abort void ia64_mca_cpu_init(void *x) { } void ia64_patch_mckinley_e9(unsigned long a, unsigned long b) { } void ia64_patch_vtop(unsigned long a, unsigned long b) { } -void hpsim_setup(char **x) { } +void hpsim_setup(char **x) +{ +#ifdef CONFIG_SMP + init_smp_config(); +#endif +} // called from mem_init... don't think s/w I/O tlb is needed in Xen //void swiotlb_init(void) { } ...looks like it IS needed diff --git a/xen/arch/ia64/xensetup.c b/xen/arch/ia64/xensetup.c index bef39ead8e..182f6ce874 100644 --- a/xen/arch/ia64/xensetup.c +++ b/xen/arch/ia64/xensetup.c @@ -260,6 +260,41 @@ printk("About to call xen_time_init()\n"); printk("About to call ac_timer_init()\n"); ac_timer_init(); // init_xen_time(); ??? + +#ifdef CONFIG_SMP + if ( opt_nosmp ) + { + max_cpus = 0; + smp_num_siblings = 1; + //boot_cpu_data.x86_num_cores = 1; + } + + smp_prepare_cpus(max_cpus); + + /* We aren't hotplug-capable yet. */ + //BUG_ON(!cpus_empty(cpu_present_map)); + for_each_cpu ( i ) + cpu_set(i, cpu_present_map); + + //BUG_ON(!local_irq_is_enabled()); + +printk("num_online_cpus=%d, max_cpus=%d\n",num_online_cpus(),max_cpus); + for_each_present_cpu ( i ) + { + if ( num_online_cpus() >= max_cpus ) + break; + if ( !cpu_online(i) ) { +printk("About to call __cpu_up(%d)\n",i); + __cpu_up(i); + } + } + + printk("Brought up %ld CPUs\n", (long)num_online_cpus()); + smp_cpus_done(max_cpus); +#endif + + + // FIXME: Should the following be swapped and moved later? schedulers_start(); do_initcalls(); printk("About to call sort_main_extable()\n"); -- 2.30.2